const originRequest = require('request')
const cheerio = require('cheerio')
const iconv = require('iconv-lite')

function request(url, callback) {
    const options = {
        url: url,
        encoding: null
    }
    originRequest(url, options, callback)
}

function findPriject() {
    const url = `https://gitee.com/meng19970630`
    request(url, function (err, res, body) {
        const html = iconv.decode(body, 'gb2312')
        const $ = cheerio.load(html)
        console.log(`本初的精选项目有`)

        // 这个是给服务端用的 类似于jquery的选择器
        $('#popular-pinned-projects .popular-project-title').each((i, item) => {
            console.log($(item).text())
        })
    })
}

findPriject()
